package com.tiancheng.trade.settlement.bo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.tiancheng.trade.settlement.enums.OrderSourceEnum;
import com.tiancheng.trade.settlement.enums.RevenueTypeEnum;
import com.tiancheng.trade.settlement.enums.SystemSourceEnum;
import com.tiancheng.trade.settlement.util.AmountUtil;
import com.tiancheng.trade.settlement.util.ObjectConvertUtil;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @Auther: Likailun
 * @Date: 10:58 2021/5/7
 * @Description: 收入明细表导出
 */
@Data
@NoArgsConstructor
public class SRevenueDetailExportBO implements Serializable {

    /**
     * 统计周期
     */
    private String statisticsCycle;
    /**
     * 收入确认类型-名称
     */
    private String revenueTypeName;
    /**
     * 业务渠道类型-名称
     */
    private String orderSourceName;
    /**
     * 机构名称
     */
    private String orgName;
    /**
     * 商户名称
     */
    private String merchantName;
    /**
     * 产品名称
     */
    private String productName;

    /**
     * 子订单应收金额-销售金额
     */
    private BigDecimal subOrderAmountTotalBD;
    /**
     * 收入确认-优惠金额
     */
    private BigDecimal discountTotalBD;
    /**
     * 子订单支付金额-结算金额
     */

    private BigDecimal productCostTotalBD;
    /**
     * 收入确认-服务成功笔数
     */
    private Integer scOrderCount;
    /**
     * 收入金额（分）
     */
    private BigDecimal revenueAmountTotalBD;
    /**
     * 平台收入比例
     *
     */
    @JsonProperty("platform_revenue_scale")
    private BigDecimal platformRevenueScale;
    /**
     * 平台收入金额
     *
     */
    @JsonProperty("platform_revenue_amount")
    private BigDecimal platformRevenueAmountBD;
    /**
     * 业务系统来源
     *  @see SystemSourceEnum
     */
    @JsonProperty("system_source")
    private String systemSource;



    public static SRevenueDetailExportBO build(SRevenueDetailQueryResBo bo){
        SRevenueDetailExportBO entity = ObjectConvertUtil.convert(bo, SRevenueDetailExportBO.class).get();
        entity.setSubOrderAmountTotalBD(AmountUtil.getYUAN(bo.getSubOrderAmountTotal()));
        entity.setDiscountTotalBD(AmountUtil.getYUAN(bo.getDiscountTotal()));
        entity.setProductCostTotalBD(AmountUtil.getYUAN(bo.getProductCostTotal()));
        entity.setRevenueAmountTotalBD(AmountUtil.getYUAN(bo.getRevenueAmountTotal()));
        entity.setPlatformRevenueAmountBD(AmountUtil.getYUAN(bo.getPlatformRevenueAmount()));
        entity.setScOrderCount(bo.getScOrderCount());
        entity.setOrderSourceName(OrderSourceEnum.getDesc(bo.getOrderSource()));
        entity.setRevenueTypeName(RevenueTypeEnum.getDesc(bo.getRevenueType()));
        return entity;
    }
}
